package com.twl.app.base.bo.batchsave;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.util.Date;
import java.util.List;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.orm.hibernate3.SessionFactoryUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.twl.app.base.entity.Checktemplet;
import com.twl.app.base.entity.Companyb;
import com.twl.app.base.entity.Miniwase;
import com.twl.app.base.entity.SalParam;
import com.twl.app.base.entity.SalSalaryData;
import com.twl.app.base.entity.SalSocialAdjust;
import com.twl.app.base.entity.Uemp;
import com.twl.app.base.util.CryptUtils;
import com.twl.common.constant.SalConstant;
import com.twl.core.framework.dao.WSHibernateDaoSupportProxy;

/**
 * 批量导入
 * @author Val
 *
 */
@Transactional
@Service
public class BatchSaveService {

	public Logger log = Logger.getLogger(BatchSaveService.class);

	@Autowired
	private WSHibernateDaoSupportProxy wSHibernateDaoSupportProxy;

	/**
	 * 批量保存考勤
	 * 
	 * @param list
	 */
	public void batchSaveImportChecktemplet(List<Checktemplet> list) {
		Connection conn = null;
		PreparedStatement stmt = null;
		PreparedStatement stmt2 = null;
		try {
			// hibernate3获得connection方法
			conn = SessionFactoryUtils.getDataSource(wSHibernateDaoSupportProxy.getSessionFactory()).getConnection();
			// 关闭自动提交
			conn.setAutoCommit(false);
			stmt = conn.prepareStatement(
					" INSERT INTO CHECKTEMPLET (DID,PERIOD,STAFFINT,STAFFNAME,DIRECTLYDEPT,STAFFJOB,HEARTMUM,LEAVEDAY,MARRYDAY,FUNERALDAY,MATERNITYDAY,SICKDAY,PERSONALDAY,LACTATIAONDAY,PAIDDAY,ABSENTDAY,WORKOVERTIME,RESTOVERTIME,HOLIDAYOVERTIME,ABAN,BBAN,EBAN,CBAN,DBAN,CABAN,CBBAN,NIGHTBAN,MORNINGBAN,OVERTIMEMEALNUM,LEAVENIANJIA,NIGHTHOUR,NIGHTCAR,CUSTOMERHOURTHREE,CUSTOMERHOURTWO,ID_NUMBER) VALUES (SEQ_CHECKTEMPLET_DID.NEXTVAL,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) ");
			stmt2 = conn.prepareStatement(" DELETE FROM  CHECKTEMPLET WHERE PERIOD = ? AND STAFFINT = ? ");

			for (Checktemplet checktemplet : list) {
				stmt.setObject(1, checktemplet.getPeriod());
				stmt.setObject(2, checktemplet.getStaffint());
				stmt.setObject(3, checktemplet.getStaffname());
				stmt.setObject(4, checktemplet.getDirectlydept());
				stmt.setObject(5, checktemplet.getStaffjob());
				stmt.setObject(6, checktemplet.getHeartmum());
				stmt.setObject(7, checktemplet.getLeaveday());
				stmt.setObject(8, checktemplet.getMarryday());
				stmt.setObject(9, checktemplet.getFuneralday());
				stmt.setObject(10, checktemplet.getMaternityday());
				stmt.setObject(11, checktemplet.getSickday());
				stmt.setObject(12, checktemplet.getPersonalday());
				stmt.setObject(13, checktemplet.getLactatiaonday());
				stmt.setObject(14, checktemplet.getPaidday());
				stmt.setObject(15, checktemplet.getAbsentday());
				stmt.setObject(16, checktemplet.getWorkovertime());
				stmt.setObject(17, checktemplet.getRestovertime());
				stmt.setObject(18, checktemplet.getHolidayovertime());
				stmt.setObject(19, checktemplet.getAban());
				stmt.setObject(20, checktemplet.getBban());
				stmt.setObject(21, checktemplet.getEban());
				stmt.setObject(22, checktemplet.getCban());
				stmt.setObject(23, checktemplet.getDban());
				stmt.setObject(24, checktemplet.getCaban());
				stmt.setObject(25, checktemplet.getCbban());
				stmt.setObject(26, checktemplet.getNightban());
				stmt.setObject(27, checktemplet.getMorningban());
				stmt.setObject(28, checktemplet.getOvertimemealnum());
				stmt.setObject(29, checktemplet.getLeavenianjia());
				stmt.setObject(30, checktemplet.getNighthour());
				stmt.setObject(31, checktemplet.getNightcar());
				stmt.setObject(32, checktemplet.getCustomerhourthree());
				stmt.setObject(33, checktemplet.getCustomerhourtwo());
				stmt.setObject(34, checktemplet.getIdNumber());

				stmt2.setObject(1, checktemplet.getPeriod());
				stmt2.setObject(2, checktemplet.getStaffint());
				stmt.addBatch();
				stmt2.addBatch();
			}
			// 批量执行
			// 先删除
			stmt2.executeBatch();
			// 再新增
			stmt.executeBatch();

			conn.commit();
			conn.setAutoCommit(true);// 提交完成后回复现场将Auto commit,还原为true,
		} catch (Exception e) {
			try {
				conn.rollback();
				conn.setAutoCommit(true);// 提交完成后回复现场将Auto commit,还原为true,
			} catch (Exception e1) {
				e1.printStackTrace();
			}
			e.printStackTrace();
		} finally {
			try {
				stmt.close();
				stmt2.close();
				conn.close();
			} catch (Exception e) {
				e.printStackTrace();
			}
		}

	}

	/**
	 * 批量保存参保比例
	 * 
	 * @param list
	 */
	public void batchSaveImportCompanyb(List<Companyb> list) {
		Connection conn = null;
		PreparedStatement stmt = null;
		PreparedStatement stmt2 = null;
		try {
			// hibernate3获得connection方法
			conn = SessionFactoryUtils.getDataSource(wSHibernateDaoSupportProxy.getSessionFactory()).getConnection();
			// 关闭自动提交
			conn.setAutoCommit(false);
			stmt = conn.prepareStatement("INSERT INTO COMPANYB (DID,NATURE,ACCUMULDAN,NURSINGDAN,HEALTHDAN,UNEMPDAN,FIRMSDAN,FERTILITYDAN,HANDIDAN,DISEASEDAN,ACCUMULPER,NURSINGPER,HEALTHPER,UNEMPPER,CARDINALDOU,CARDIALADD,NATEURETEXT)  VALUES(SEQ_COMPANYB_DID.NEXTVAL,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
			stmt2 = conn.prepareStatement(" DELETE FROM  COMPANYB WHERE NATURE = ? ");

			for (Companyb companyb : list) {
				stmt.setObject(1, companyb.getNature());
				stmt.setObject(2, companyb.getAccumuldan());
				stmt.setObject(3, companyb.getNursingdan());
				stmt.setObject(4, companyb.getHealthdan());
				stmt.setObject(5, companyb.getUnempdan());
				stmt.setObject(6, companyb.getFirmsdan());
				stmt.setObject(7, companyb.getFertilitydan());
				stmt.setObject(8, companyb.getHandidan());
				stmt.setObject(9, companyb.getDiseasedan());
				stmt.setObject(10, companyb.getAccumulper());
				stmt.setObject(11, companyb.getNursingper());
				stmt.setObject(12, companyb.getHealthper());
				stmt.setObject(13, companyb.getUnempper());
				stmt.setObject(14, companyb.getCardinaLdou());
				stmt.setObject(15, companyb.getCardialadd());
				stmt.setObject(16, companyb.getNateuretext());

				stmt2.setObject(1, companyb.getNature());

				stmt.addBatch();
				stmt2.addBatch();
			}
			// 批量执行
			// 先删除
			stmt2.executeBatch();
			// 再新增
			stmt.executeBatch();
			conn.commit();
			conn.setAutoCommit(true);// 提交完成后回复现场将Auto commit,还原为true,
		} catch (Exception e) {
			try {
				conn.rollback();
				conn.setAutoCommit(true);// 提交完成后回复现场将Auto commit,还原为true,
			} catch (Exception e1) {
				e1.printStackTrace();
			}
			e.printStackTrace();
		} finally {
			try {
				stmt.close();
				conn.close();
			} catch (Exception e) {
				e.printStackTrace();
			}
		}

	}

	/**
	 * 批量保存最低工资基数
	 * 
	 * @param list
	 */
	public void batchSaveImportMiniwase(List<Miniwase> list) {
		Connection conn = null;
		PreparedStatement stmt = null;
		PreparedStatement stmt2 = null;
		try {
			// hibernate3获得connection方法
			conn = SessionFactoryUtils.getDataSource(wSHibernateDaoSupportProxy.getSessionFactory()).getConnection();
			// 关闭自动提交
			conn.setAutoCommit(false);
			stmt = conn.prepareStatement("INSERT INTO MINIWASE (DID,ENGLI,ENGTYPE,IDTION,VMONEY,IDTEXT,IS_DELETE)  VALUES(SEQ_MINIWASE_ID.NEXTVAL,?,?,?,?,?,?)");
			stmt2 = conn.prepareStatement("UPDATE MINIWASE SET IS_DELETE ='" + SalConstant.IS_DELTE + "' WHERE ENGTYPE = ? AND VMONEY = ? AND IS_DELETE = '" + SalConstant.NOT_DELETE + "' ");

			for (Miniwase miniwase : list) {
				stmt.setObject(1, miniwase.getEngli());
				stmt.setObject(2, miniwase.getEngtype());
				stmt.setObject(3, miniwase.getIdtion());
				stmt.setObject(4, miniwase.getVmoney());
				stmt.setObject(5, miniwase.getIdtext());
				stmt.setObject(6, SalConstant.NOT_DELETE);

				stmt2.setObject(1, miniwase.getEngtype());
				stmt2.setObject(2, miniwase.getVmoney());

				stmt.addBatch();
				stmt2.addBatch();
			}
			// 批量执行
			// 先删除
			stmt2.executeBatch();
			// 再新增
			stmt.executeBatch();
			conn.commit();
			conn.setAutoCommit(true);// 提交完成后回复现场将Auto commit,还原为true,
		} catch (Exception e) {
			try {
				conn.rollback();
				conn.setAutoCommit(true);// 提交完成后回复现场将Auto commit,还原为true,
			} catch (Exception e1) {
				e1.printStackTrace();
			}
			e.printStackTrace();
		} finally {
			try {
				stmt.close();
				stmt2.close();
				conn.close();
			} catch (Exception e) {
				e.printStackTrace();
			}
		}

	}

	/**
	 * 批量保存薪资系统系统参数
	 * 
	 * @param list
	 */
	public void batchSaveImportSalParam(List<SalParam> list) {
		Connection conn = null;
		PreparedStatement stmt = null;
		PreparedStatement stmt2 = null;
		try {
			// hibernate3获得connection方法
			conn = SessionFactoryUtils.getDataSource(wSHibernateDaoSupportProxy.getSessionFactory()).getConnection();
			// 关闭自动提交
			conn.setAutoCommit(false);
			stmt = conn.prepareStatement("INSERT INTO SAL_PARAM (PARAM_ID,PARAM_TYPE,PARAM_TYPE_NAME,PARAM_KEY,PARAM_KEY_NAME,PARAM_VALUE,VERSION,CREATE_TIME,CREATOR,MODIFY_TIME,MODIFIER,REMARK,IS_DELETE)  VALUES(SEQ_SAL_PARAM.NEXTVAL,?,?,?,?,?,?,?,?,?,?,?,?)");
			stmt2 = conn.prepareStatement("UPDATE SAL_PARAM SET IS_DELETE = '" + SalConstant.IS_DELTE + "' WHERE PARAM_TYPE = ? AND PARAM_KEY = ? AND IS_DELETE = '" + SalConstant.NOT_DELETE + "' ");

			for (SalParam salParam : list) {
				stmt.setObject(1, salParam.getParamType());
				stmt.setObject(2, salParam.getParamTypeName());
				stmt.setObject(3, salParam.getParamKey());
				stmt.setObject(4, salParam.getParamKeyName());
				stmt.setObject(5, salParam.getParamValue());
				stmt.setObject(6, SalConstant.ZERO);
				stmt.setObject(7, new java.sql.Date(new Date().getTime()));
				stmt.setObject(8, salParam.getCreator());
				stmt.setObject(9, new java.sql.Date(new Date().getTime()));
				stmt.setObject(10, salParam.getModifier());
				stmt.setObject(11, salParam.getRemark());
				stmt.setObject(12, SalConstant.NOT_DELETE);

				stmt2.setObject(1, salParam.getParamType());
				stmt2.setObject(2, salParam.getParamKey());

				stmt.addBatch();
				stmt2.addBatch();
			}
			// 批量执行
			// 先删除
			stmt2.executeBatch();
			// 再新增
			stmt.executeBatch();
			conn.commit();
			conn.setAutoCommit(true);// 提交完成后回复现场将Auto commit,还原为true,
		} catch (Exception e) {
			try {
				conn.rollback();
				conn.setAutoCommit(true);// 提交完成后回复现场将Auto commit,还原为true,
			} catch (Exception e1) {
				e1.printStackTrace();
			}
			e.printStackTrace();
		} finally {
			try {
				stmt.close();
				stmt2.close();
				conn.close();
			} catch (Exception e) {
				e.printStackTrace();
			}
		}

	}

	/**
	 * 批量保存薪资数据
	 * 
	 * @param list
	 */
	public void batchSaveImportSalSalaryData(List<SalSalaryData> list) {
		Connection conn = null;
		PreparedStatement stmt = null;
		PreparedStatement stmt2 = null;
		try {
			log.info(" 加密开始......");
			long start = System.currentTimeMillis();
			list = CryptUtils.encrypt(list);
			log.info("共加密" + list.size() + "条记录" + "耗时" + (System.currentTimeMillis() - start) + "毫秒...");

			// hibernate3获得connection方法
			conn = SessionFactoryUtils.getDataSource(wSHibernateDaoSupportProxy.getSessionFactory()).getConnection();
			// 关闭自动提交
			conn.setAutoCommit(false);
			stmt = conn.prepareStatement(
					"INSERT INTO SAL_SALARY_DATA (DID,PERIOD,STAFFINT,ID_NUMBER,NAME,MONTHLYAWARD,HALF_YEAR_AWRAD,YEARAWRAD,DUY_WRAD,INCEN_WRAD,MAIN_ALL,OTHER_ALL,MATERNITY_PAY,RECOMM_WRAD,HIGH_TEMP,DUTYADDS,AFTERBONUS,PARENTSONLY,EMIC_COPTION,ATAX_ADSUBIT,DUTYDEDUCTION,AUTO_WRAD,CUS_WRAD,CUSIC_WRAD,CUSTY_WRAD,CUSAPF_WRAD,CUSTH_WRAD,COLL_WRAD,COLLTH_WRAD,DIRECT_COMM,DIRETH_COMM,DIREPER_WRAD,DIREAM_WRAD,DIREAN_WRAD,DIRETH_WRAD,HFISUB_WRAD,HFISH_WRAD,HFIPER_WRAD,HFIMIN_WRAD,HFISTH_WRAD,BRANCH_WRAD,BRANPT_WRAD,BRANCA_WRAD,BRANHG_WRAD,BRANTH_WRAD,BRANQK_WRAD,BRANFW_WRAD,BRANDTL_WRAD,BRANDMAX_WRAD,BRANSW_IWRAD,BRANOF_WRAD,BRANCOMM_WRAD,BRANTRAN_WRAD,BRADPAY_WRAD,BRANSUPMH_WRAD,BRANDEP_WRAD,BRANPER_WRAD,BRANATO_WRAD,BRANOER_WRAD,BRANEXT_WRAD,BRANRISK_WRAD,NOBRAND_WRAD,BRANDBIT_WRAD,OTHER_WRAD,RULET_PATS,BRANCHMONEY,STAFFTYPE,STAFFTYPES,DUYYEAR,IS_DELETE,VERSION,CREATOR,CREATE_TIME,MODIFIER,MODIFY_TIME,REMARK,ANNUAL_WAGE_CONVERT,DUTYMEALS,DUTYGOLD,DES_KEY)  VALUES(SEQ_SAL_SALARY_DATA.NEXTVAL,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
			stmt2 = conn.prepareStatement("UPDATE SAL_SALARY_DATA SET IS_DELETE = '" + SalConstant.IS_DELTE + "' WHERE PERIOD = ? AND STAFFINT = ? AND IS_DELETE = '" + SalConstant.NOT_DELETE + "' ");

			for (SalSalaryData salSalaryData : list) {
				stmt.setObject(1, salSalaryData.getPeriod());
				stmt.setObject(2, salSalaryData.getStaffint());
				stmt.setObject(3, salSalaryData.getIdNumber());
				stmt.setObject(4, salSalaryData.getName());
				stmt.setObject(5, salSalaryData.getMonthlyaward());
				stmt.setObject(6, salSalaryData.getHalfYearAwrad());
				stmt.setObject(7, salSalaryData.getYearawrad());
				stmt.setObject(8, salSalaryData.getDuyWrad());
				stmt.setObject(9, salSalaryData.getIncenWrad());
				stmt.setObject(10, salSalaryData.getMainAll());
				stmt.setObject(11, salSalaryData.getOtherAll());
				stmt.setObject(12, salSalaryData.getMaternityPay());
				stmt.setObject(13, salSalaryData.getRecommWrad());
				stmt.setObject(14, salSalaryData.getHighTemp());
				stmt.setObject(15, salSalaryData.getDutyadds());
				stmt.setObject(16, salSalaryData.getAfterbonus());
				stmt.setObject(17, salSalaryData.getParentsonly());
				stmt.setObject(18, salSalaryData.getEmicCoption());
				stmt.setObject(19, salSalaryData.getAtaxAdsubit());
				stmt.setObject(20, salSalaryData.getDutydeduction());
				stmt.setObject(21, salSalaryData.getAutoWrad());
				stmt.setObject(22, salSalaryData.getCusWrad());
				stmt.setObject(23, salSalaryData.getCusicWrad());
				stmt.setObject(24, salSalaryData.getCustyWrad());
				stmt.setObject(25, salSalaryData.getCusapfWrad());
				stmt.setObject(26, salSalaryData.getCusthWrad());
				stmt.setObject(27, salSalaryData.getCollWrad());
				stmt.setObject(28, salSalaryData.getCollthWrad());
				stmt.setObject(29, salSalaryData.getDirectComm());
				stmt.setObject(30, salSalaryData.getDirethComm());
				stmt.setObject(31, salSalaryData.getDireperWrad());
				stmt.setObject(32, salSalaryData.getDireamWrad());
				stmt.setObject(33, salSalaryData.getDireanWrad());
				stmt.setObject(34, salSalaryData.getDirethWrad());
				stmt.setObject(35, salSalaryData.getHfisubWrad());
				stmt.setObject(36, salSalaryData.getHfishWrad());
				stmt.setObject(37, salSalaryData.getHfiperWrad());
				stmt.setObject(38, salSalaryData.getHfiminWrad());
				stmt.setObject(39, salSalaryData.getHfisthWrad());
				stmt.setObject(40, salSalaryData.getBranchWrad());
				stmt.setObject(41, salSalaryData.getBranptWrad());
				stmt.setObject(42, salSalaryData.getBrancaWrad());
				stmt.setObject(43, salSalaryData.getBranhgWrad());
				stmt.setObject(44, salSalaryData.getBranthWrad());
				stmt.setObject(45, salSalaryData.getBranqkWrad());
				stmt.setObject(46, salSalaryData.getBranfwWrad());
				stmt.setObject(47, salSalaryData.getBrandtlWrad());
				stmt.setObject(48, salSalaryData.getBrandmaxWrad());
				stmt.setObject(49, salSalaryData.getBranswIwrad());
				stmt.setObject(50, salSalaryData.getBranofWrad());
				stmt.setObject(51, salSalaryData.getBrancommWrad());
				stmt.setObject(52, salSalaryData.getBrantranWrad());
				stmt.setObject(53, salSalaryData.getBradpayWrad());
				stmt.setObject(54, salSalaryData.getBransupmhWrad());
				stmt.setObject(55, salSalaryData.getBrandepWrad());
				stmt.setObject(56, salSalaryData.getBranperWrad());
				stmt.setObject(57, salSalaryData.getBranatoWrad());
				stmt.setObject(58, salSalaryData.getBranoerWrad());
				stmt.setObject(59, salSalaryData.getBranextWrad());
				stmt.setObject(60, salSalaryData.getBranriskWrad());
				stmt.setObject(61, salSalaryData.getNobrandWrad());
				stmt.setObject(62, salSalaryData.getBrandbitWrad());
				stmt.setObject(63, salSalaryData.getOtherWrad());
				stmt.setObject(64, salSalaryData.getRuletPats());
				stmt.setObject(65, salSalaryData.getBranchmoney());
				stmt.setObject(66, salSalaryData.getStafftype());
				stmt.setObject(67, salSalaryData.getStafftypes());
				stmt.setObject(68, salSalaryData.getDuyyear());
				stmt.setObject(69, SalConstant.NOT_DELETE);
				stmt.setObject(70, SalConstant.ZERO);
				stmt.setObject(71, salSalaryData.getCreator());
				stmt.setObject(72, new java.sql.Date(new Date().getTime()));
				stmt.setObject(73, salSalaryData.getModifier());
				stmt.setObject(74, new java.sql.Date(new Date().getTime()));
				stmt.setObject(75, salSalaryData.getRemark());
				stmt.setObject(76, salSalaryData.getAnnualWageConvert());
				stmt.setObject(77, salSalaryData.getDutymeals());
				stmt.setObject(78, salSalaryData.getDutygold());
				stmt.setObject(79, salSalaryData.getDesKey());

				stmt2.setObject(1, salSalaryData.getPeriod());
				stmt2.setObject(2, salSalaryData.getStaffint());

				stmt.addBatch();
				stmt2.addBatch();
			}
			// 批量执行
			// 先删除
			stmt2.executeBatch();
			// 再新增
			stmt.executeBatch();
			conn.commit();
			conn.setAutoCommit(true);// 提交完成后回复现场将Auto commit,还原为true,
		} catch (Exception e) {
			try {
				conn.rollback();
				conn.setAutoCommit(true);// 提交完成后回复现场将Auto commit,还原为true,
			} catch (Exception e1) {
				e1.printStackTrace();
			}
			e.printStackTrace();
		} finally {
			try {
				stmt.close();
				stmt2.close();
				conn.close();
			} catch (Exception e) {
				e.printStackTrace();
			}
		}

	}

	/**
	 * 批量保存社保调整
	 * 
	 * @param list
	 */
	public void batchSaveImportSalSocialAdjust(List<SalSocialAdjust> list) {
		Connection conn = null;
		PreparedStatement stmt = null;
		PreparedStatement stmt2 = null;
		try {
			// hibernate3获得connection方法
			conn = SessionFactoryUtils.getDataSource(wSHibernateDaoSupportProxy.getSessionFactory()).getConnection();
			// 关闭自动提交
			conn.setAutoCommit(false);
			stmt = conn.prepareStatement("INSERT INTO SAL_SOCIAL_ADJUST (ID,PERIOD,STAFFINT,ID_NUMBER,NAME,ACCUMUL_UNIT_ADJUST,NURSING_UNIT_ADJUST,HEALTH_UNIT_ADJUST,UNEMP_UNIT_ADJUST,FIRMS_UNIT_ADJUST,FERTILITY_UNIT_ADJUST,DISABLED_AND_OTHER,ACCUMUL_PER_ADJUST,NURSING_PER_ADJUST,HEALTH_PER_ADJUST,UNEMP_PER_ADJUST,IS_DELETE,VERSION,CREATOR,CREATE_TIME,MODIFIER,MODIFY_TIME,REMARK,DES_KEY)  VALUES(SEQ_SAL_SOCIAL_ADJUST.NEXTVAL,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
			stmt2 = conn.prepareStatement("UPDATE SAL_SOCIAL_ADJUST SET IS_DELETE = '" + SalConstant.IS_DELTE + "' WHERE PERIOD = ? AND STAFFINT = ? AND IS_DELETE = '" + SalConstant.NOT_DELETE + "' ");

			for (SalSocialAdjust salSocialAdjust : list) {

				stmt.setObject(1, salSocialAdjust.getPeriod());
				stmt.setObject(2, salSocialAdjust.getStaffint());
				stmt.setObject(3, salSocialAdjust.getIdNumber());
				stmt.setObject(4, salSocialAdjust.getName());
				stmt.setObject(5, salSocialAdjust.getAccumulUnitAdjust());
				stmt.setObject(6, salSocialAdjust.getNursingUnitAdjust());
				stmt.setObject(7, salSocialAdjust.getHealthUnitAdjust());
				stmt.setObject(8, salSocialAdjust.getUnempUnitAdjust());
				stmt.setObject(9, salSocialAdjust.getFirmsUnitAdjust());
				stmt.setObject(10, salSocialAdjust.getFertilityUnitAdjust());
				stmt.setObject(11, salSocialAdjust.getDisabledAndOther());
				stmt.setObject(12, salSocialAdjust.getAccumulPerAdjust());
				stmt.setObject(13, salSocialAdjust.getNursingPerAdjust());
				stmt.setObject(14, salSocialAdjust.getHealthPerAdjust());
				stmt.setObject(15, salSocialAdjust.getUnempPerAdjust());
				stmt.setObject(16, SalConstant.NOT_DELETE);
				stmt.setObject(17, SalConstant.ZERO);
				stmt.setObject(18, salSocialAdjust.getCreator());
				stmt.setObject(19, new java.sql.Date(new Date().getTime()));
				stmt.setObject(20, salSocialAdjust.getModifier());
				stmt.setObject(21, new java.sql.Date(new Date().getTime()));
				stmt.setObject(22, salSocialAdjust.getRemark());
				stmt.setObject(23, salSocialAdjust.getDesKey());

				stmt2.setObject(1, salSocialAdjust.getPeriod());
				stmt2.setObject(2, salSocialAdjust.getStaffint());

				stmt.addBatch();
				stmt2.addBatch();
			}
			// 批量执行
			// 先删除
			stmt2.executeBatch();
			// 再新增
			stmt.executeBatch();
			conn.commit();
			conn.setAutoCommit(true);// 提交完成后回复现场将Auto commit,还原为true,
		} catch (Exception e) {
			try {
				conn.rollback();
				conn.setAutoCommit(true);// 提交完成后回复现场将Auto commit,还原为true,
			} catch (Exception e1) {
				e1.printStackTrace();
			}
			e.printStackTrace();
		} finally {
			try {
				stmt.close();
				stmt2.close();
				conn.close();
			} catch (Exception e) {
				e.printStackTrace();
			}
		}

	}

	/**
	 * 批量保存员工
	 * 
	 * @param list
	 */
	public void batchSaveImportUemp(List<Uemp> list) {

		Connection conn = null;
		PreparedStatement stmt = null;
		PreparedStatement stmt2 = null;
		try {
			log.info(" 加密开始......");
			long start = System.currentTimeMillis();
			list = CryptUtils.encrypt(list);
			log.info("共加密" + list.size() + "条记录" + "耗时" + (System.currentTimeMillis() - start) + "毫秒...");

			// hibernate3获得connection方法
			conn = SessionFactoryUtils.getDataSource(wSHibernateDaoSupportProxy.getSessionFactory()).getConnection();
			// 关闭自动提交
			conn.setAutoCommit(false);
			stmt = conn.prepareStatement("INSERT INTO UEMP (DID,STAFFINT,STAFFNAME,STAFFTYPE,STAFFTYPES,GRADE,DEPT,UMPSTAFF,DATEENTRY,DATEDIMI,DELSTAFF,MONEYCOUNT,PROMEDEINT,MAINLAND,DATEPROMED,ASSAILEDCOM,CARD,DURATIONDATE,TEAN,COMMISSION,COSTCENTRE,HUKOU,ISMANAGE,CARDLEVEL,JOBGRADE,JOBSORT,ACCBACK,ACCUMULDAN,FERTILITYDAN,FIRMSDAN,HEALTHDAN,NURSINGDAN,UNEMPDAN,WORK_PLACE,DES_KEY)  VALUES(SEQ_UEMP_ID.NEXTVAL,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
			stmt2 = conn.prepareStatement("UPDATE UEMP SET DELSTAFF = '" + SalConstant.IS_DELTE + "' WHERE STAFFINT = ? AND DELSTAFF = '" + SalConstant.NOT_DELETE + "' ");

			for (Uemp uemp : list) {
				stmt.setObject(1, uemp.getStaffint());
				stmt.setObject(2, uemp.getStaffname());
				stmt.setObject(3, uemp.getStafftype());
				stmt.setObject(4, uemp.getStafftypes());
				stmt.setObject(5, uemp.getGrade());
				stmt.setObject(6, uemp.getDept());
				stmt.setObject(7, uemp.getUmpstaff());
				stmt.setObject(8, uemp.getDateentry());
				stmt.setObject(9, uemp.getDatedimi());
				stmt.setObject(10, Integer.valueOf(SalConstant.NOT_DELETE));
				stmt.setObject(11, uemp.getMoneycount());
				stmt.setObject(12, uemp.getPromedeint());
				stmt.setObject(13, uemp.getMainland());
				stmt.setObject(14, uemp.getDatepromed());
				stmt.setObject(15, uemp.getAssailedcom());
				stmt.setObject(16, uemp.getCard());
				stmt.setObject(17, uemp.getDurationdate());
				stmt.setObject(18, uemp.getTean());
				stmt.setObject(19, uemp.getCommission());
				stmt.setObject(20, uemp.getCostcentre());
				stmt.setObject(21, uemp.getHukou());
				stmt.setObject(22, uemp.getIsmanage());
				stmt.setObject(23, uemp.getCardlevel());
				stmt.setObject(24, uemp.getJobgrade());
				stmt.setObject(25, uemp.getJobsort());
				stmt.setObject(26, uemp.getAccback());
				stmt.setObject(27, uemp.getAccumuldan());
				stmt.setObject(28, uemp.getFertilitydan());
				stmt.setObject(29, uemp.getFirmsdan());
				stmt.setObject(30, uemp.getHealthdan());
				stmt.setObject(31, uemp.getNursingdan());
				stmt.setObject(32, uemp.getUnempdan());
				stmt.setObject(33, uemp.getWorkPlace());
				stmt.setObject(34, uemp.getDesKey());

				stmt2.setObject(1, uemp.getStaffint());

				stmt.addBatch();
				stmt2.addBatch();
			}
			// 批量执行
			// 先删除
			stmt2.executeBatch();
			// 再新增
			stmt.executeBatch();

			conn.commit();
			conn.setAutoCommit(true);// 提交完成后回复现场将Auto commit,还原为true,
		} catch (Exception e) {
			try {
				conn.rollback();
				conn.setAutoCommit(true);// 提交完成后回复现场将Auto commit,还原为true,
			} catch (Exception e1) {
				e1.printStackTrace();
			}
			e.printStackTrace();
		} finally {
			try {
				stmt.close();
				stmt2.close();
				conn.close();
			} catch (Exception e) {
				e.printStackTrace();
			}
		}

	}

}
